package com.hu.imitationalipay;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ContactsAdapter extends BaseAdapter {
	private Context context;
	private List<ContactsMessage> ContactsList;

	public ContactsAdapter(Context context, List<ContactsMessage> ContactsList) {
		this.context = context;
		this.ContactsList = ContactsList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return ContactsList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return ContactsList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView = LayoutInflater.from(context).inflate(
				R.layout.select_contacts_item, null);
		ContactsMessage mContacts = ContactsList.get(position);
		TextView name = (TextView) convertView.findViewById(R.id.contact);
		TextView phone = (TextView) convertView.findViewById(R.id.number);
		name.setText(mContacts.getContactsName());
		phone.setText(mContacts.getContactsPhone());
		return convertView;
	}

}
